﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Threading.Tasks;

namespace ClockCodeEditor
{


    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : UserControl
    {
        #region 属性
        /// <summary>
        /// 线程时间
        /// </summary>
        private DispatcherTimer timer = new DispatcherTimer();
        /// <summary>
        /// lable的位置
        /// </summary>
        private Thickness lablePoint = new Thickness();
        #endregion

        #region 构造函数
        public MainWindow()
        {
            InitializeComponent();
            timer.Tick += new EventHandler(timer_Tick);
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Start();
        }
        #endregion

        #region 事件
        void timer_Tick(object sender, EventArgs e)
        {
            pbHours.Value = DateTime.Now.Hour;
            pbMinutes.Value = DateTime.Now.Minute;
            pbSeconds.Value = DateTime.Now.Second;
            lblHours.Content = DateTime.Now.Hour.ToString();
            lblMinutes.Content = DateTime.Now.Minute.ToString();
            lblSeconds.Content = DateTime.Now.Second.ToString();

            lablePoint = lblHours.Margin;
            lablePoint.Top = 100 - 100 * DateTime.Now.Hour / 24;
            lblHours.Margin = lablePoint;

            lablePoint = lblMinutes.Margin;
            lablePoint.Top = 100 - 100 * DateTime.Now.Minute / 60;
            lblMinutes.Margin = lablePoint;

            lablePoint = lblSeconds.Margin;
            lablePoint.Top = 100 - 100 * DateTime.Now.Second / 60;
            lblSeconds.Margin = lablePoint;
        }
        #endregion


    }
}
